<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page session="true"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<jsp:include page="common/style.jsp" />
<style>
#login-box {
	width: 260px;
	padding: 20px;
	margin: auto;
	background: #fff;
	-webkit-border-radius: 2px;
	-moz-border-radius: 2px;
	border: 1px solid #000;
        
}
</style>
</head>
<body onload='document.loginForm.username.focus();'>
    
    <c:if test="${pageContext.request.userPrincipal.name != null}">
        <div class="container">
        
            <jsp:include page="common/header.jsp" />
            <div class="hero-unit">
                <center>
                    <h2 class="form-signin-heading">Jesteś już zalogowany!</h2>
                    <a href="${pageContext.request.contextPath}/">Powrót do strony głównej</a>
                </center>
            </div>
        </div>
    </c:if>
    <c:if test="${pageContext.request.userPrincipal.name == null}">
    <div class="container">
        
            <jsp:include page="common/header.jsp" />
        <div class="hero-unit">
            <div id="login-box">

                    
                <h2 class="form-signin-heading">Zaloguj się:</h2>
                    
                    <c:if test="${not empty error}">
                            <div class="alert alert-danger">${error}</div>
                    </c:if>
                    <c:if test="${not empty msg}">
                            <div class="alert alert-info">${msg}</div>
                    </c:if>

                        <form name='loginForm' class="form-signin" role="form"
                            action="<c:url value='/j_spring_security_check' />" method='POST'>
                                
                               
                            <input type="email" name='username' class="input-block-level" placeholder="Email" required="required">
                               
                            
                            <input type="password" name='password' class="input-block-level" placeholder="Hasło" required="required" />
                            
                            <button class="btn btn-lg btn-primary btn-block" name="submit" type="submit">Zaloguj</button>                                    

                            <input type="hidden" name="${_csrf.parameterName}"
                                    value="${_csrf.token}" />

                        </form>
                                   
                                    <a href="${pageContext.request.contextPath}/">Powrót do strony głównej</a>
                                    
            </div>
        </div>
                                
    </div>

    </c:if>
    <jsp:include page="common/footer.jsp" />
</body>
</html>